const { Menu, BrowserWindow } = require('electron')

// 菜单模板
let template = [
  {
    label: '前端技能',
    submenu: [
      {
        label: 'JavaScript',
        // 绑定快捷键
        accelerator: `ctrl+n`,
        // 加入click事件
        click: () => {
          win = new BrowserWindow({
            width: 400,
            height: 400,
            webPreferences: { nodeIntegration: true }
          })
          win.loadFile('test1.html')
          win.on('closed', () => {
            win = null
          })
        }
      },
      { label: 'TypeScript' }
    ]
  },
  {
    label: '后端技能',
    submenu: [{ label: 'golang' }, { label: 'Python' }]
  }
]

// 设置菜单
let m = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(m)
